package com.mes.cloud.web;

import com.mes.cloud.api.dto.request.area.MarketDevelopmentPageRequest;
import com.mes.cloud.api.dto.request.area.MarketDevelopmentRequest;
import com.mes.cloud.api.dto.request.area.MarketDevelopmentUpdateRequest;
import com.mes.cloud.api.dto.response.area.MarketDevelopmentDto;
import com.mes.cloud.common.CommPager;
import com.mes.cloud.common.JsonResult;
import com.mes.cloud.service.BaseAreaMarketDevelopmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @author dy
 * @email dongyi@shinho.net.cn
 * @version 2019-08-23 11:03:50
 */
@Api(tags = "区域市场发展", value = "区域市场发展接口")
@RestController
@RequestMapping(value = "/baseAreaMarketDevelopment")
public class BaseAreaMarketDevelopmentController  {

    private BaseAreaMarketDevelopmentService baseAreaMarketDevelopmentService;

    @Autowired
    public BaseAreaMarketDevelopmentController(BaseAreaMarketDevelopmentService baseAreaMarketDevelopmentService) {
        this.baseAreaMarketDevelopmentService = baseAreaMarketDevelopmentService;
    }

    /**
     * 功能: 区域市场发展分页查询
     *
     * @param pageRequest
     * @return JsonResult<CommPager<BaseAreaMarketDevelopmentDto>>
     */
    @ApiOperation(value = "区域市场发展分页查询", notes = "区域市场发展分页查询")
    @PostMapping(value = "/pageList")
    public JsonResult<CommPager<MarketDevelopmentDto>> pageList(@Valid @RequestBody MarketDevelopmentPageRequest pageRequest) {
        return baseAreaMarketDevelopmentService.pageList(pageRequest);
    }

    /**
     * 功能: 区域市场发展新增
     *
     * @param baseAreaMarketDevelopmentRequest
     * @return JsonResult
     */
    @ApiOperation(value = "区域市场发展新增", notes = "区域市场发展新增")
    @PostMapping(value = "/add")
    public JsonResult add(@Valid @RequestBody MarketDevelopmentRequest baseAreaMarketDevelopmentRequest) {
        return baseAreaMarketDevelopmentService.add(baseAreaMarketDevelopmentRequest);
    }

    /**
     * 功能: 区域市场发展修改
     *
     * @param marketDevelopmentRequest
     * @return JsonResult
     */
    @ApiOperation(value = "区域市场发展修改", notes = "区域市场发展修改")
    @PostMapping(value = "/update")
    public JsonResult update(@Valid @RequestBody MarketDevelopmentUpdateRequest marketDevelopmentRequest) {
        return baseAreaMarketDevelopmentService.update(marketDevelopmentRequest);

    }

    /**
     * @description 查询行政区划详情
     * @author dongyi
     * @date 2019-08-05 16:50
     **/
    @ApiOperation(value = "市场发展阶段详情", notes = "市场发展阶段详情")
    @ApiImplicitParam(paramType = "String", name = "id", value = "市场发展阶段ID", required = true)
    @GetMapping(value = "get/{id}")
    public JsonResult<MarketDevelopmentDto> get(@NotEmpty(message = "id不能为空") @PathVariable String id) {
        return baseAreaMarketDevelopmentService.get(id);
    }

    /**
     * 功能: 区域市场发展列表查询
     *
     * @param pageRequest
     * @return JsonResult<CommPager<BaseAreaMarketDevelopmentDto>>
     */
    @ApiOperation(value = "区域市场发展列表查询", notes = "区域市场发展列表查询")
    @PostMapping(value = "/list")
    public JsonResult<List<MarketDevelopmentDto>> list(@Valid @RequestBody MarketDevelopmentRequest pageRequest) {
        return baseAreaMarketDevelopmentService.list(pageRequest);
    }

    @ApiOperation(value = "区域市场发展列表查询", notes = "区域市场发展列表查询")
    @PostMapping(value = "/listByChannelIds")
    public JsonResult<List<MarketDevelopmentDto>> listByChannelIds(@RequestBody MarketDevelopmentRequest marketDevelopmentRequest) {
        return baseAreaMarketDevelopmentService.listByChannelIds(marketDevelopmentRequest);
    }
}
